package com.xx.ems.model;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * @author xxx
 * @date 2014-2-25
 * @version 1.0
 * 描述: 领用表
 */
@Entity
public class Receive {
	/**
	 * 描述：主键
	 */
	private Integer rid;
	/**
	 * 描述：设备表关联对象
	 */
	private Equipments equipments;
	/**
	 * 描述：用户表关联对象 (归还操作人)
	 */
	private Users rusers;
	/**
	 * 描述：归还时间
	 */
	private Date return_time;
	/**
	 * 描述：领用单号表关联对象
	 */
	private ReceiveNum receiveNum;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="rid",unique=true,nullable=false)
	public Integer getRid() {
		return rid;
	}
	public void setRid(Integer rid) {
		this.rid = rid;
	}
	@ManyToOne(targetEntity=Equipments.class)
	@JoinColumn(name="fk_eid")
	public Equipments getEquipments() {
		return equipments;
	}
	public void setEquipments(Equipments equipments) {
		this.equipments = equipments;
	}
	@ManyToOne(targetEntity=Users.class)
	@JoinColumn(name="fk_ruid")
	public Users getRusers() {
		return rusers;
	}
	public void setRusers(Users rusers) {
		this.rusers = rusers;
	}
	@Column(name="return_time")
	public Date getReturn_time() {
		return return_time;
	}
	public void setReturn_time(Date return_time) {
		this.return_time = return_time;
	}
	@ManyToOne(targetEntity=ReceiveNum.class)
	@JoinColumn(name="fk_rid")
	public ReceiveNum getReceiveNum() {
		return receiveNum;
	}
	public void setReceiveNum(ReceiveNum receiveNum) {
		this.receiveNum = receiveNum;
	}
	/**
	 * 描述: 将实体的属性及相应的值转换成Map类型(为了方便转换成json格式后前台调用) 
	 * @return
	 * @date 2014-3-4
	 */
	public Map<String, Object> toHashMap(){
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("rid", getRid());
		map.put("ename", getEquipments().getEname());
		map.put("enumber", getEquipments().getEnumber());
		map.put("rusers", getRusers().getUsername());
		map.put("return_time", getReturn_time());
		return map;
	}
}